/*
 * @Author: your name
 * @Date: 2022-02-01 13:55:31
 * @LastEditTime: 2022-03-12 16:31:23
 * @LastEditors: Please set LastEditors
 * @Description: 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 * @FilePath: \vue3-ts-food-admin\mock\index.ts
 */
import { MockMethod } from "vite-plugin-mock";
import Mock from "mockjs";

Mock.Random.extend({
  happiness: function () {
    return this.pick([
      "包间：寿比南山",
      "包间：万事如意",
      "包间：福如东海",
      "包间：鹏程万里",
      "包间：凤凰于飞",
      "包间：一帆风顺",
      "包间：锦绣前程",
      "包间：喜气洋洋",
      "包间：繁荣兴旺",
      "包间：聪明过人",
      "包间：百年好合",
      "包间：长命百岁",
      "包间：恭贺新禧",
      "包间：才高八斗",
      "包间：朝朝暮暮",
      "包间：情投意合",
      "包间：日进斗金",
      "包间：繁荣昌盛",
      "包间：相亲相爱",
      "包间：春风得意",
      "包间：时运亨通",
      "包间：欣欣向荣",
      "一楼",
      "二楼",
    ]);
  },
  goodsName: function () {
    return this.pick([
      "红烧茄子",
      "鱼香肉丝",
      "麻婆豆腐",
      "啤酒鸭",
      "地三鲜",
      "番茄牛腩",
      "家常茄子",
    ]);
  },
});

const seatCategoryData = Mock.mock({
  "result|10": [
    {
      "id|+1": 1,
      name: () => Mock.Random.happiness(),
      "available|1": true,
    },
  ],
});

let seatCategoryDetailList = null;

const profitData = Mock.mock({
  "CommodityProfit|0-4000": 0,
  "freight|-100-0": -20,
  "wages|-1000--500": -600,
  "discount|-200-0": 0,
  "serviceCharge|-50-0": 0,
});

export default [
  {
    url: "/api/login",
    method: "post",
    response: (query) => {
      return {
        code: 200,
        result:
          "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhY2NvdW50IjoiYWRtaW4iLCJpc0J1aWx0SW4iOjAsInVzZXJJZCI6MSwidXNlck5hbWUiOiLotoXnuqfnrqHnkIblkZgiLCJkYXRlIjoiMjAyMi0wMS0yNiAxNTozMDoyMSIsImlhdCI6MTY0MzE4MjIyMSwiZXhwIjoxNjQ4MTgyMjIxLCJhdWQiOiJjbG91ZCIsImlzcyI6ImNsb3VkIn0.OO8fJl4l5_2WtjNBkcZkLjdI5fSWiHvfHdpRjHgpxdQ",
      };
    },
  },
  {
    url: "/api/dishList",
    method: "get",
    response: () => {
      return {
        code: 200,
        result: "sadadwadas",
      };
    },
  },
  {
    url: "/api/getUserInfo",
    method: "get",
    response: () => {
      return {
        code: 200,
        result: {
          name: "boss",
          company: "德辰大饭店",
          imgUrl: "./toutiao.jpg",
        },
      };
    },
  },
  {
    url: "/api/getCompanyDetailById",
    method: "get",
    response: () => {
      return {
        code: 200,
        result: {
          companyName: "德辰大饭店",
          logoUrl: "./timg.jpg",
          tel: 18888888888,
          addres: "四川省成都市高新区吉泰路香年广场t3栋30楼",
          sales: 500,
          orders: 30,
          goodsCegetory: 26,
          goodsNumber: 600,
          memberNumber: 120,
          supplierNumber: 11,
        },
      };
    },
  },
  {
    url: "/api/getSeatCatrgory",
    method: "get",
    response: () => {
      return {
        code: 200,
        result: [{ id: -1, name: "全部" }, ...seatCategoryData.result],
      };
    },
  },
  {
    url: "/api/getDeliverList",
    method: "get",
    response: () => {
      const list = Mock.mock({
        "result|5-15": [
          {
            "id|+1": 1,
            name: () => Mock.Random.cname(),
          },
        ],
      });

      return {
        code: 200,
        result: list.result,
      };
    },
  },
  {
    url: "/api/getSeatListByCatrgoryId",
    method: "get",
    response: ({ query }) => {
      const { id, name } = query;
      // if (!seatCategoryDetailList) {
      seatCategoryDetailList = Mock.mock({
        "result|1-10": [
          {
            "id|+1": 1,
            categoryId: id,
            categoryName: name,
            "sales|50-2000": 1,
            "available|1": true,
            "name|+1": [
              "坐席1",
              "坐席2",
              "坐席3",
              "坐席4",
              "坐席5",
              "坐席6",
              "坐席7",
              "坐席8",
              "坐席9",
              "坐席10",
            ],
          },
        ],
      });
      // }
      return {
        code: 200,
        result: seatCategoryDetailList.result,
      };
    },
  },
  {
    url: "/api/getOrderGoodsDemo",
    method: "get",
    response: () => {
      const getOrderGoodsDemo = Mock.mock({
        "result|1-4": [
          {
            name: () => Mock.Random.goodsName(),
            "id|+1": 1,
            "price|20-40": 20,
            "count|1-3": 1,
          },
        ],
      });

      return {
        code: 200,
        result: getOrderGoodsDemo.result,
      };
    },
  },
  {
    url: "/api/getProfitDistribution",
    method: "get",
    response: () => {
      return {
        code: 200,
        result: profitData,
      };
    },
  },
  {
    url: "/api/getPaymentInfo",
    method: "get",
    response: () => {
      const paymentInfo = Mock.mock({
        "membership|200-500": 200,
        "cash|200-500": 200,
        "wechat|200-500": 200,
        "alipay|200-500": 200,
        "pos|200-500": 200,
        "bankCard|200-500": 200,
      });
      return {
        code: 200,
        result: paymentInfo,
      };
    },
  },
  {
    url: "/api/getSalesCategory",
    method: "get",
    response: () => {
      const data = Mock.mock({
        "result|5-10": [
          {
            "count|20-100": 20,
            categoryName: "现炒快餐",
            "salesValue|100-1000": 100,
            "profitRatio|0-100.0-10": 1,
            "profit|0-1000": 0,
          },
        ],
      });

      return {
        code: 200,
        result: data.result,
      };
    },
  },
] as MockMethod[];
